package LC;

/**
 * @ClassName LC714
 * @Description: TODO
 * @Author hl
 * @Date 2020/5/23
 * @Version V1.0
 **/
public class LC714 {
    public static void main(String[] args) {
        System.out.println(maxProfit(new int[]{1, 3, 2, 8, 4, 9},2));
    }

    public static int maxProfit(int[] prices, int fee) {
        int sell=0;
        int buy=-prices[0];
        for(int i=1;i<prices.length;i++){
            buy=Math.max(buy,sell-prices[i]);
            sell=Math.max(sell,buy+prices[i])-2;
        }
        return sell;
    }
}
